home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / term / term_47a_pch.lha / Source / gtlayout-38.3 / LTP_SelectKeys.c < prev    next >
C/C++ Source or Header  |  1996-11-10  |  3KB  |  172 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_PICKSHORTCUTS
  15. VOID
  16. LTP_SelectKeys(LayoutHandle *handle,ObjectNode *group)
  17. {
  18.     LONG         bunch;
  19.     ObjectNode    *node;
  20.     ULONG         page;
  21.     STRPTR        *lines;
  22.  
  23.     SCANPAGE(group,node,page)
  24.     {
  25.         bunch = 0;
  26.         lines = NULL;
  27.  
  28.         switch(node->Type)
  29.         {
  30.             case GROUP_KIND:
  31.  
  32.                 LTP_SelectKeys(handle,node);
  33.                 break;
  34.  
  35.             case TEXT_KIND:
  36.  
  37.                 if(!node->Special.Text.UsePicker)
  38.                     break;
  39.  
  40.             case PASSWORD_KIND:
  41.             case STRING_KIND:
  42.             case FRACTION_KIND:
  43.  
  44.                 if(node->Type != TEXT_KIND && node->Special.String.UsePicker)
  45.                     bunch = 255;
  46.  
  47.             case BUTTON_KIND:
  48.  
  49.                 if(node->Type == BUTTON_KIND)
  50.                 {
  51.                     if(!node->NoKey && node->Special.Button.Lines)
  52.                         lines = node->Special.Button.Lines;
  53.                 }
  54.  
  55.             case BOOPSI_KIND:
  56.             case CHECKBOX_KIND:
  57.             case INTEGER_KIND:
  58.  
  59.                 bunch++;
  60.  
  61.             case LISTVIEW_KIND:
  62.             case MX_KIND:
  63.             case CYCLE_KIND:
  64.             case PALETTE_KIND:
  65.             case SCROLLER_KIND:
  66.             case SLIDER_KIND:
  67. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  68.             case POPUP_KIND:
  69. #endif
  70. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  71.             case TAB_KIND:
  72. #endif
  73. #ifdef DO_LEVEL_KIND
  74.             case LEVEL_KIND:
  75. #endif    /* DO_LEVEL_KIND */
  76. #ifdef DO_TAPEDECK_KIND
  77.             case TAPEDECK_KIND:
  78. #endif    /* DO_TAPEDECK_KIND */
  79.  
  80.                 bunch++;
  81.  
  82.                 if(node->Label && !node->Key && !node->NoKey)
  83.                 {
  84.                     LONG    i,len,code,glyph;
  85.                     STRPTR    label;
  86.  
  87.                     do
  88.                     {
  89.                         if(lines)
  90.                         {
  91.                             if(!(label = *lines++))
  92.                                 break;
  93.                         }
  94.                         else
  95.                             label = node->Label;
  96.  
  97.                         len = strlen(label);
  98.  
  99.                         for(i = 0 ; i < len ; i++)
  100.                         {
  101.                             glyph    = ToLower(label[i]);
  102.                             code    = -1;
  103.  
  104.                             switch(bunch)
  105.                             {
  106.                                 case 1:    // Support increment & decrement
  107.  
  108.                                     if(LTP_Keys[0][glyph] && LTP_Keys[1][glyph])
  109.                                         code = LTP_Keys[0][glyph];
  110.  
  111.                                     break;
  112.  
  113.                                         // Any one will do
  114.  
  115.                                 case 2:
  116.  
  117.                                     if(LTP_Keys[0][glyph])
  118.                                         code = LTP_Keys[0][glyph];
  119.                                     else
  120.                                     {
  121.                                         if(LTP_Keys[1][glyph] && LTP_Keys[0][glyph])
  122.                                         {
  123.                                             if(ToLower(LTP_Keys[1][glyph]) == glyph)
  124.                                                 code = LTP_Keys[0][glyph];
  125.                                         }
  126.                                     }
  127.  
  128.                                     break;
  129.                             }
  130.  
  131.                             if(code != -1 && !handle->Keys[code])
  132.                             {
  133.                                 if(lines)
  134.                                 {
  135.                                     node->Special.Button.KeyStroke = &label[i];
  136.  
  137.                                     lines = NULL;
  138.                                 }
  139.                                 else
  140.                                 {
  141.                                     STRPTR newLabel;
  142.  
  143.                                     if(newLabel = LTP_Alloc(handle,len + 2))
  144.                                     {
  145.                                         node->Label = newLabel;
  146.  
  147.                                         if(i)
  148.                                             CopyMem(label,newLabel,i);
  149.  
  150.                                         newLabel[i] = '_';
  151.  
  152.                                         strcpy(&newLabel[i + 1],label + i);
  153.                                     }
  154.                                 }
  155.  
  156.                                 node->Key = code;
  157.  
  158.                                 handle->Keys[code] = handle->Keys[LTP_Keys[1][code]] = TRUE;
  159.  
  160.                                 break;
  161.                             }
  162.                         }
  163.                     }
  164.                     while(lines);
  165.                 }
  166.  
  167.                 break;
  168.         }
  169.     }
  170. }
  171. #endif
  172.